<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.db.conn"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.db.Pagination"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<jsp:include flush="true" page="${basePath}/admin/head.jsp"></jsp:include>
 </head>


 
 <body>

 <div class="card">
        <ul class="nav nav-tabs page-tabs">
            <li class="active"><a>待发货商品订单</a></li>
        </ul>
        <div class="tab-content" style="min-height: 450px;">

<table style="width: 100%;">
	<tr>
		<td align="center">
			                <form action="<%=path %>/admin/orders/orders_Manage.jsp" method="post">

<strong> 订单编号:</strong><input name="txt_no" type="text" id="txt_no" style="width:150px;"  />
<strong> 姓名:</strong><input name="txt_username" type="text" id="txt_username" style="width:150px;"  />
<strong> 手机号码:</strong><input name="txt_phone" type="text" id="txt_phone" style="width:150px;"  />

                <input name="search" type="submit" border="0" class="btn btn-primary"	value='查询' />
                </form>


		</td>
	</tr>
	<tr>
		<td align="center">
			 <%
//定义四个分页会用到的变量
int pageSize=15;
int pageNow=1;//默认显示第一页
int rowCount=0;//该值从数据库中查询
int pageCount=0;//该值是通过pageSize和rowCount
//接受用户希望显示的页数（pageNow）
String s_pageNow=request.getParameter("pageNum");
if(s_pageNow!=null){
//接收到了pageNow
pageNow=Integer.parseInt(s_pageNow);
}

String where="  flag=0  and oflag='等待发货' ";
if(request.getParameter("txt_no")!=null)
{
where+=" and no like '%"+request.getParameter("txt_no")+"%' ";
}

if(request.getParameter("txt_username")!=null)
{
where+=" and username like '%"+request.getParameter("txt_username")+"%' ";
}

if(request.getParameter("txt_phone")!=null)
{
where+=" and phone like '%"+request.getParameter("txt_phone")+"%' ";
}


conn cn=new conn();


ResultSet rs=cn.query("select count(*) from orders a where "+where);
if(rs.next()){
rowCount=rs.getInt(1);
}

//计算pageCount
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
//查询出需要显示的记录
 
rs=cn.query("select  * from orders a where "+where+" order by no desc limit "+pageSize*(pageNow-1)+", "+pageSize);

%>

	<table cellspacing="0" border="0" style="width:100%;border-collapse:collapse;"  >
		<tr>
    <th >订单编号</th>
    <th >用户ID</th>
    <th >姓名</th>
    <th >手机号码</th>
    <th >收货地址</th>

    <th >订单金额</th>
    <th >订单状态</th>
    <th >提交时间</th>

			<th scope="col">操作</th>		</tr>
		<%
while(rs.next()){
%>
		<tr align="center" >
  			<td><%=rs.getString("no") %></td>
  			<td><%=rs.getString("uid") %></td>
  			<td><%=rs.getString("username") %></td>
  			<td><%=rs.getString("phone") %></td>
  			<td><%=rs.getString("address") %></td>

  			<td><%=rs.getString("smoney") %></td>
  			<td><%=rs.getString("oflag") %></td>
  			<td><%=rs.getString("otime") %></td>

			<td >
           <a href="<%=path %>/admin/orders/orders_Detail.jsp?id=<%=rs.getString("no") %>">详细</a>&nbsp;
				<a href="<%=path %>/orders_Delete?id=<%=rs.getString("no") %>&f=1">发货</a>
           <a href="<%=path %>/orders_Delete?id=<%=rs.getString("no") %>">删除</a>
		</tr>
<%} %>

</table>
<table width=100%>
	<tbody>
		<tr>
			<td align="center">
				<%=Pagination.getPagination(pageNow,pageCount,rowCount,request.getRequestURI())
				%>
			</td>
		</tr>
</table>


        </div>
    </div>


</body>
</html>



